package br.org.etec.dotcao.model;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.codehaus.jackson.annotate.JsonIgnore;

@Table (name = "tspecies")
@Entity 
public class Species extends AbstractEntity {

	private static final long serialVersionUID = 1L;

	@Column
	private String nome;
	
	@JsonIgnore
	@OneToMany(cascade={CascadeType.ALL}, mappedBy="species")
	private List<Race> races;
	
	public void addRace(Race race){
		if(race == null){
			return;
		}
		
		race.setSpecies(this);
		
		getRaces().add(race);
	}
	
	public List<Race> getRaces() {
		if(races == null){
			races = new ArrayList<Race>();
		}
		
		return races;
	}
	
	public void setRaces(List<Race> races) {
		this.races = races;
	}
	
	public String getNome() {
		return nome;
	}

	public void setNome(String nome) {
		this.nome = nome;
	}
}
